const package = require('./package.json')
module.exports = {
    apps: app(process.env.CLUSTER_NUM)
}

function app(num) {
    const arr = []
    for (let i = 0; i < num; i++) {
        arr.push({
            name: `single-${i}`,
            namespace: package.name,
            script: 'bin/www',
            cmd: './',
            // watch: true,
            restart_delay: 2000,
            max_memory_restart: '300M',
            instance: 1,
            // args: ['--no-color'],
            exec_mode: 'cluster',
            // ignore_watch: [
            //     'node_modules',
            //     'logs_box',
            //     'bin',
            //     'public',
            //     'package-lock.json',
            //     'pnpm-lock.yaml'
            // ],
            out_file: `./log_box/pm2-logs/${process.env.MODE}/out.log`,
            error_file: `./log_box/pm2-logs/${process.env.MODE}/err.log`,
            merge_logs: false,
            log_date_format: 'YYYY-MM-DD HH:mm:ss'
        })
        
    }
    return arr
}